#include "subctrl.h"
#include "com.h"
#include "sys.h"
#include <string.h>

static uint8_t data_pack[8] = {SUBCTRL_FRAME_HEADER};

void SubCtrl_Query(uint8_t address)
{
    data_pack[1] = address;
    data_pack[2] = SUBCTRL_TYPE_QUERY;

    ADD8_Calculation(data_pack, sizeof(data_pack));
    ComSubCtrl_Send(data_pack, sizeof(data_pack));
}

void SubCtrl_Power(uint8_t address, float power)
{
    data_pack[1] = address;
    data_pack[2] = SUBCTRL_TYPE_POWER;
    memcpy(&data_pack[3], (uint8_t *)&power, sizeof(float));

    ADD8_Calculation(data_pack, sizeof(data_pack));
    ComSubCtrl_Send(data_pack, sizeof(data_pack));
}